<template>
  <a-modal
    :title="modalTitle"
    :width="1200"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @cancel="handleCancel"
  >
    <detail-list title="" :col="2">
      <detail-list-item term="检定单号">{{ model.no }}</detail-list-item>
      <detail-list-item term="检定人">{{ model.name }}</detail-list-item>
      <detail-list-item term="检定单位">{{ model.requirement }}</detail-list-item>
      <detail-list-item term="检定日期">{{ model.lastDate }}</detail-list-item>
      <detail-list-item term="创建时间">{{ model.createdTime }}</detail-list-item>
    </detail-list>
    <detail-list title="" :col="1">
      <detail-list-item term="备注">{{ model.requirement }}</detail-list-item>
    </detail-list>
    <title-divider title="检定图片" width="90px"></title-divider>
    <detail-list title="" :col="2">
      <detail-list-item term="" v-if="model.checkImgList != null && model.checkImgList.length > 0">
        <viewer :images="model.checkImgList" @inited="inited" ref="viewer" :index="1" >
          <img v-for="item in model.checkImgList" :src="item.url" :key="item.id" class="image">
        </viewer>
      </detail-list-item>
      <detail-list-item term="" v-if="model.checkImgList == null || model.checkImgList.length === 0">
        暂无
      </detail-list-item>
    </detail-list>
    <title-divider title="检定文件" width="90px"></title-divider>
    <detail-list title="" :col="2">
      <detail-list-item term="">
        <a-upload
          :multiple="true"
          :fileList="BaseTool.UPLOAD.transImg(model.checkFileList)"
        >
        </a-upload>
      </detail-list-item>
    </detail-list>
<!--    <a-tabs type="card" default-active-key="1">
      <a-tab-pane key="1" tab="点检标准参数">
        <a-table
          bordered
          :data-source="data"
          :columns="columns"
          tableLayout="auto"
          rowKey="id"
        >
        </a-table>
      </a-tab-pane>
    </a-tabs>-->
    <template slot="footer">
      <a-button :loading="confirmLoading" type="primary" @click="handleCancel()">返回</a-button>
    </template>
  </a-modal>
</template>

<script>
import DetailList from '@/components/tools/DetailList'

const DetailListItem = DetailList.Item

export default {
  name: 'CheckStandardDetail',
  components: {
    DetailList,
    DetailListItem
  },
  data () {
    return {
      confirmLoading: false,
      mdl: {},
      modalTitle: null,
      visible: false,
      // 下拉框map
      typeMap: {},
      periodTypeMap: {},
      actionTypeMap: {},
      enableMap: {},
      model: {
        'name': null,
        'no': null,
        'type': null,
        'part': null,
        'enable': null,
        'requirement': null,
        'standardHours': null,
        'remark': null,
        'createdUserId': null,
        'updateUserId': null,
        'updateUserName': null,
        'updateTime': null
      },
      rowSelection: {
        onChange: (selectedRowKeys, selectedRows) => {
          this.selectedRowKeys = selectedRowKeys
          this.selectedRows = selectedRows
        }
      },
      // 表头
      columns: [
        {
          title: '名称',
          dataIndex: 'name',
          scopedSlots: { customRender: 'name' }
        },
        {
          title: '类型',
          dataIndex: 'type',
          scopedSlots: { customRender: 'type' }
          // customRender: (text, record, index) => {
          //   return this.BaseTool.Table.getMapText(this.typeMap, text)
          // }
        },
        {
          title: '上限',
          dataIndex: 'upperLimit',
          scopedSlots: { customRender: 'upperLimit' }
        },
        {
          title: '下限',
          dataIndex: 'lowerrLimit',
          scopedSlots: { customRender: 'lowerrLimit' }
        },
        {
          title: '参考值',
          dataIndex: 'referenceValue',
          scopedSlots: { customRender: 'referenceValue' }
        },
        {
          title: '正常选型',
          dataIndex: 'normalSelection',
          scopedSlots: { customRender: 'normalSelection' }
        },
        {
          title: '说明',
          dataIndex: 'instruction',
          scopedSlots: { customRender: 'instruction' }
        }
      ],
      data: [],
      options: {
        rowSelection: {
          selectedRowKeys: this.selectedRowKeys
        }
      }
    }
  },
  created () {
    // 下拉框map
    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_TYPE)
    this.enableMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
    this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
    this.actionTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_ACTION_TYPE)
  },
  methods: {
    base (record) {
      this.visible = true
      this.modalTitle = '详情'
      this.model = record
      this.data = record.paramList
    },
    handleCancel () {
      this.visible = false
      this.confirmLoading = false
    },
    inited (viewer) {
      this.$viewer = viewer

    }
  }
}
</script>
<style scoped>
/* For demo */
.ant-carousel {
  width: 300px;
  height: 300px;
}
.ant-carousel >>> .slick-slide {
  text-align: center;
  height: 300px;
  line-height: 300px;
  overflow: hidden;
}

.ant-carousel >>> .slick-slide h3 {
  color: #fff;
}

.image {
  width: calc(20% - 10px);
  cursor: pointer;
  margin: 5px;
  display: inline-block;
}
</style>